﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using ZhangLogSysV1d0;
/// <summary>
/// 打印日志,记录打印任务的处理过程
/// zhangfujian-2019-03
/// </summary>
namespace TmU220PrintHelperV2d0.Entity
{
    /// <summary>
    /// 打印日志
    /// </summary>
    [XmlRoot("打印日志")]
    [Serializable]
    public class PrintLogV3d0
    {
        [XmlAttribute("打印任务id")]
        public int id { get; set; }
        [XmlAttribute("打印任务uid")]
        public string uid { get; set; }
        [XmlAttribute("任务添加时间")]
        public DateTime addtime { get; set; }
        [XmlAttribute("打印机名称")]
        public string act_printer { get; set; }
        [XmlAttribute("状态")]
        public int status { get; set; }
        [XmlAttribute("打印时间")]
        public DateTime printtime { get; set; }
        [XmlAttribute("桌号")]
        public string tableno { get; set; }
        [XmlAttribute("打印编号")]
        public string print_no { get; set; }
        [XmlArray("打印内容明细项集"), XmlArrayItem("打印内容明细项")]
        public List<string> DetailList { get; set; }
        [XmlArray("打印过程描述集"), XmlArrayItem("打印过程描述")]
        public List<string> PrintProcessDescriptionList { get; set; }
        public PrintLogV3d0()
        {
            id = 0;
            addtime = DateTime.MinValue;
            status = -1;
            printtime = DateTime.MinValue;
            DetailList = new List<string>();
            PrintProcessDescriptionList = new List<string>();
        }  
        public PrintLogV3d0(rms_order_print_main printMain)
        {
            id = printMain.id;
            uid = printMain.uid;
            addtime = printMain.addtime.HasValue? printMain.addtime.Value:DateTime.MinValue;
            act_printer = printMain.act_printer;
            status = printMain.status.HasValue? printMain.status.Value:-1;
            printtime = printMain.printtime.HasValue ? printMain.printtime.Value : DateTime.MinValue; ;
            tableno = printMain.tableno;
            print_no = printMain.print_no.HasValue ? printMain.print_no.Value.ToString("D3") : "";
            DetailList = new List<string>();
            PrintProcessDescriptionList = new List<string>();
        }
        public PrintLogV3d0(PrintTaskV2d0 printTask)
        {
            id = printTask.DataOfPrintTask.id;
            uid = printTask.DataOfPrintTask.uid;
            addtime = printTask.DataOfPrintTask.addtime.HasValue ? printTask.DataOfPrintTask.addtime.Value : DateTime.MinValue;
            act_printer = printTask.DataOfPrintTask.act_printer;
            status = printTask.DataOfPrintTask.status.HasValue ? printTask.DataOfPrintTask.status.Value : -1;
            printtime = printTask.DataOfPrintTask.printtime.HasValue ? printTask.DataOfPrintTask.printtime.Value : DateTime.MinValue; ;
            tableno = printTask.DataOfPrintTask.tableno;
            print_no = printTask.DataOfPrintTask.print_no.HasValue ? printTask.DataOfPrintTask.print_no.Value.ToString("D3") : "";
            DetailList = printTask.PrintTaskItemList.FindAll(x=>x.AreaType==AreaTypeV2d0.Detail).Select(x=>x.Content).ToList();
            PrintProcessDescriptionList = new List<string>();
        }

    }
  
}
